package com.meevle.model {
	
	import com.adobe.cairngorm.model.IModelLocator;
	import com.meevle.vo.LoginVO;
	import com.meevle.vo.UserVO;
	
	import mx.collections.ArrayCollection;

	[Bindable]
	public class ViewModelLocator implements IModelLocator {
	
		private static var instance:ViewModelLocator;

		public function ViewModelLocator(enforcer:SingletonEnforcer) {
			if (enforcer == null) {
				throw new Error( "You Can Only Have One ViewModelLocator" );
			}
		}

		public static function getInstance() : ViewModelLocator {
			if (instance == null) {
				instance = new ViewModelLocator( new SingletonEnforcer );
			}
			return instance;
		}
		
		

		// DEFINE YOUR VARIABLES HERE
		public var workflowState:uint = APPLICATION_HOME_STATE;
		
		public var error:Error;
		
		public var loginStatus:uint = NOT_LOGGED_IN;
		public var isLoggedIn:Boolean = false;
		public var loginError:Error;
		
		public var registrationError:Error;
		public var registrationStatus:Boolean = false;
		
		public var createNewSetError:Error;
		public var createNewSetStatus:Boolean = false;
		
		public var currentUser:UserVO;
		public var login:LoginVO;
		
		public var setList:ArrayCollection;

		// DEFINE VIEW CONSTANTS
		public static const APPLICATION_HOME_STATE:uint = 0;
		public static const APPLICATION_STUDIO_STATE:uint = 1;
		public static const APPLICATION_CANTEEN_STATE:uint = 2;
		
		public static const NOT_LOGGED_IN:uint = 0;
		public static const LOGGING_IN:uint = 1;
		public static const LOGGED_IN:uint = 2;
		
		public function reset() : void {
			loginStatus = ViewModelLocator.NOT_LOGGED_IN;
			isLoggedIn = false;
			workflowState = APPLICATION_HOME_STATE;
			currentUser = null;
			error = null;
			login = null;
			
			registrationError = null;
			registrationStatus = false;
			createNewSetError = null;
			createNewSetStatus = false;
		}
	}
}

// Utility Class to Deny Access to Constructor
class SingletonEnforcer {}